import defaultSettings from '../../settings'

const {
	title,
	logo,
	showSettings,
	fixedHeader,
	sidebarLogo,
	tagsView,
	version
} = defaultSettings

const state = {
	title: title, //侧边栏标题
	logo:logo, //侧边栏logo
	showSettings: showSettings,
	fixedHeader: fixedHeader, //是否固定顶部
	sidebarLogo: sidebarLogo, //是否显示log
	tagsView: localStorage.getItem('tagsView')||tagsView, //是否显示头部标签
	version:version,//版本号
}

const mutations = {
	CHANGE_SETTING: (state, {
		key,
		value
	}) => {
		// eslint-disable-next-line no-prototype-builtins
		if (state.hasOwnProperty(key)) {
			state[key] = value
		}
	},
	SET_TAGES_VIEW: (state, tagsView) => {
		state.tagsView = tagsView
		localStorage.setItem('tagsView', tagsView)
	}
}

const actions = {
	changeSetting({
		commit
	}, data) {
		commit('CHANGE_SETTING', data)
	},
	//固定头部
	setTagsView({commit},tagsView){
		commit('SET_TAGES_VIEW',tagsView)
	}
}

export default {
	namespaced: true,
	state,
	mutations,
	actions
}
